home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 8 / FM Towns Free Software Collection 8.iso / t_os / gpen32k / source / src / gpen16s.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-01  |  2.5 KB  |  125 lines

  1. /*****************************************************************
  2.  
  3.         G-Pen16専用部
  4.                             Copyright(C) 1991,1992,1993 Okome
  5. *****************************************************************/
  6.  
  7. #include    <stdio.h>
  8. #include    <stdlib.h>
  9. #include    <string.h>
  10. #include    <EGB.h>
  11. #include    <MOS.h>
  12. #include    <Normlib.h>
  13. #include    <GPen16.h>
  14. #include    <GPenSub.c>
  15.  
  16. void wsize( int mb, int s )
  17. {
  18.     static int k=3;
  19.     int h = 2;
  20.     wget();
  21.     wpg(0);
  22.     boxf( (NX1-h)*bi-1, (NY1-h)*bi-1, (NX2+h+1)*bi, (NY2+h+1)*bi, BCL );
  23.     wkugiri(0);
  24.     nx[k] = NX1;
  25.     ny[k] = NY1;
  26.     if (mb & 1)
  27.         k = (k+1) % (5+s);
  28.     else
  29.     {
  30.         k = (k-1);
  31.         if (k<0)
  32.             k = 4+s;
  33.     }
  34.     wb = wallbl[k];
  35.     NX4 = (8/bi) << k;
  36.     NY4 = NX4;
  37.     NX1 = nx[k];
  38.     NY1 = ny[k];
  39.     wpg(1);
  40.     wput();
  41.     wpg(0);
  42.     if (NX4<WX4)    wkugiri(1);
  43.     biboxbf( NX1, NY1, NX2, NY2, 0, 4, 4 );
  44.     wpg(1);
  45. }
  46.  
  47. /*    カラー選択パレット    */
  48. void mcolms( int j )        /*    カラーバー  □表示    */
  49. {
  50.     int c;
  51.     c = ( mcl[0] / (1 << (j*5))) & 0x1f;
  52.     j = 2 - j;
  53.     boxf( PALX*bi + 1  , PALY*bi + j   *PALB*bi + 1,
  54.           PALX*bi + 255, PALY*bi +(j+1)*PALB*bi - 1, 0 );
  55.     boxb( PALX*bi + c * 8 + 2, PALY*bi + j   *PALB*bi + 2,
  56.           PALX*bi + c * 8 + 7, PALY*bi +(j+1)*PALB*bi - 1, 8 );
  57.     boxb( PALX*bi + c * 8 + 1, PALY*bi + j   *PALB*bi + 1,
  58.           PALX*bi + c * 8 + 6, PALY*bi +(j+1)*PALB*bi - 2, 15 );
  59. }
  60.  
  61. void mcols( int k )
  62. {
  63.     int j;
  64.     if ( k != mcl[0] )
  65.     {
  66.         mcl[0] = k;
  67.         boxf( PCX1, PCY1, PCX2, PCY2, mcl[0]);
  68.         for ( k = 0; k <= 2; k++ )
  69.         {
  70.             EGB_writeMode( work, 3 );
  71.             boxf(PALX    , PALY+(k+1)*PALB-2,
  72.                  PALX+127, PALY+(k+1)*PALB-1, 0x1f * (1 << ((2 - k) * 5)));
  73.             EGB_writeMode( work, 2 );
  74.             boxf(PALX    , PALY+(k+1)*PALB-2,
  75.                  PALX+127, PALY+(k+1)*PALB-1,
  76.                  mcl[0] & (0x7fff - 0x1f * (1 << ((2 - k) * 5))));
  77.         }
  78.         EGB_writeMode( work, 0 );
  79.         wpg(0);
  80.         for ( j=0; j<=2; j++)
  81.             mcolms(j);
  82.         wpg(1);
  83.     }
  84. }
  85.  
  86. void ptnsave16( char *name, int sx, int sy )
  87. {
  88.     int x, y, p;
  89.     FILE *fp;
  90.     if ((fp = fopen( name, "wb")) == NULL )
  91.     {    return;    }
  92.     for (p=0; p<=3; p++ )
  93.     {
  94.         for ( y=0; y<BY4/sy; y++ )
  95.         {
  96.             for ( x=0; x<BX4/sx; x++ )
  97.             {
  98.                 egbget(BX1+x*sx,BY1+y*sy,BX1+sx-1+x*sx,BY1+sy-1+y*sy,b);
  99.                 fwrite(b, 1, sx*sy*Cb/8, fp);
  100.             }
  101.         }
  102.     }
  103.     fclose(fp);
  104. }
  105.  
  106. void ptnload16( char *name, int sx, int sy )
  107. {
  108.     int x, y, p;
  109.     FILE *fp;
  110.     if ((fp = fopen( name, "rb")) == NULL )
  111.     {    return;    }
  112.     for (p=0; p<=3; p++ )
  113.     {
  114.         for ( y=0; y<BY4/sy; y++ )
  115.         {
  116.             for ( x=0; x<BY4/sx; x++ )
  117.             {
  118.                 if (fread(b, 1, sx*sy*Cb/8, fp))
  119.                     egbput(BX1+x*sx,BY1+y*sy,BX1+sx-1+x*sx,BY1+sy-1+y*sy,b);
  120.             }
  121.         }
  122.     }
  123.     fclose(fp);
  124. }
  125.